package com.example.administrator.danpin.viewpager;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * Created by Administrator on 2017/1/16.
 */

public class ViewPagerAdapter extends FragmentPagerAdapter{

    private List<Fragment> data;
    private List<String> titles;

    public ViewPagerAdapter(FragmentManager fm,List<Fragment> data,List<String> titles) {
        super(fm);
        this.data=data;
        this.titles=titles;
    }


    @Override
    public Fragment getItem(int position) {
        return data.get(position);
    }

    @Override
    public int getCount() {
        return data!=null?data.size():0;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }
}
